int main() {
    string n;
    cin >> n;

    map<string, string> b = {
        {"zero", "0"}, {"one", "1"}, {"two", "2"}, {"three", "3"}, 
        {"four", "4"}, {"five", "5"}, {"six", "6"}, {"seven", "7"}, 
        {"eight", "8"}, {"nine", "9"}
    };

    bool prime(int x) {
        if (x == 1) {
            return false;
        }
        for (int i = 2; i <= sqrt(x); i++) {
            if (x % i == 0) {
                return false;
            }
        }
        return true;
    }

    string lst = "";
    int count = 0;
    for (char i : n) {
        if (i >= '1' && i <= '9') {
            count = 1;
        }
    }
    if (count == 1) {
        cout << "Wrong input" << endl;
    } else {
        for (char j : n) {
            lst += b[string(1, j)];
        }
        int num = stoi(lst);
        int count_1 = 0;
        int count_2 = 0;
        int k = num;
        while (!prime(k)) {
            k++;
            count_1++;
        }
        int count_3 = num;
        while (!prime(count_3)) {
            count_3--;
            count_2++;
        }
        if (count_1 <= count_2) {
            cout << k << endl;
        } else {
            cout << count_3 << endl;
        }
    }

    return 0;
}